package hr.infomare.drrh.pojo;

// Generated 08.12.2011. 12:34:10 by Hibernate Tools 3.2.1.GA

import hr.infomare.drrh.pomocni.PomocnaDatum;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;

import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.MessageHeader;
import budgetuserlibrary.gw.fmis.ibm.hr.infotypes.PaymentExecution;

/**
 * Payexec generated by hbm2java
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "PAYEXEC")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Payexec implements java.io.Serializable {

	private Integer bufmisdoc;
	private Integer refdocid;
	private String bufmisven;
	private String f41vid;
	private String f41svi;
	private BigDecimal amount;
	private BigDecimal invlcam;
	private String payref;
	private String paydesc;
	private String payecstty;
	private Integer paydate;
	private String iscess;
	private Long resmsgid;
	private Date datetimews;
	private Date timews;

	public Payexec() {
	}

	@Id
	@Column(name = "BUFMISDOC", unique = true, nullable = false, precision = 9, scale = 0)
	public Integer getBufmisdoc() {
		return this.bufmisdoc;
	}

	public void setBufmisdoc(Integer bufmisdoc) {
		this.bufmisdoc = bufmisdoc;
	}

	@Column(name = "REFDOCID", precision = 9, scale = 0)
	public Integer getRefdocid() {
		return this.refdocid;
	}

	public void setRefdocid(Integer refdocid) {
		this.refdocid = refdocid;
	}

	@Column(name = "BUFMISVEN", length = 7)
	public String getBufmisven() {
		return this.bufmisven;
	}

	public void setBufmisven(String bufmisven) {
		this.bufmisven = bufmisven;
	}

	@Column(name = "F41VID", length = 50)
	public String getF41vid() {
		return this.f41vid;
	}

	public void setF41vid(String f41vid) {
		this.f41vid = f41vid;
	}

	@Column(name = "F41SVI", nullable = false, length = 50)
	public String getF41svi() {
		return this.f41svi;
	}

	public void setF41svi(String f41svi) {
		this.f41svi = f41svi;
	}

	@Column(name = "AMOUNT", nullable = false, precision = 15)
	public BigDecimal getAmount() {
		return this.amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	@Column(name = "INVLCAM", nullable = false, precision = 15)
	public BigDecimal getInvlcam() {
		return this.invlcam;
	}

	public void setInvlcam(BigDecimal invlcam) {
		this.invlcam = invlcam;
	}

	@Column(name = "PAYREF", length = 50)
	public String getPayref() {
		return this.payref;
	}

	public void setPayref(String payref) {
		this.payref = payref;
	}

	@Column(name = "PAYDESC", length = 120)
	public String getPaydesc() {
		return this.paydesc;
	}

	public void setPaydesc(String paydesc) {
		this.paydesc = paydesc;
	}

	@Column(name = "PAYECSTTY", length = 50)
	public String getPayecstty() {
		return this.payecstty;
	}

	public void setPayecstty(String payecstty) {
		this.payecstty = payecstty;
	}

	@Column(name = "PAYDATE", nullable = false, precision = 8, scale = 0)
	public Integer getPaydate() {
		return this.paydate;
	}

	public void setPaydate(Integer paydate) {
		this.paydate = paydate;
	}

	@Column(name = "ISCESS", nullable = false, length = 1)
	public String getIscess() {
		return this.iscess;
	}

	public void setIscess(String iscess) {
		this.iscess = iscess;
	}

	@Column(name = "RESMSGID", precision = 9, scale = 0)
	public Long getResmsgid() {
		return this.resmsgid;
	}

	public void setResmsgid(Long resmsgid) {
		this.resmsgid = resmsgid;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "DATETIMEWS", length = 10)
	public Date getDatetimews() {
		return this.datetimews;
	}

	public void setDatetimews(Date datetimews) {
		this.datetimews = datetimews;
	}

	@Temporal(TemporalType.TIME)
	@Column(name = "TIMEWS", length = 8)
	public Date getTimews() {
		return this.timews;
	}

	public void setTimews(Date timews) {
		this.timews = timews;
	}

	public void postaviVrijednosti(PaymentExecution paymentExecution,
			MessageHeader messageHeader, Resmsg resMsg) {
		bufmisdoc = bufmisdoc == null ? NumberUtils.toInt(paymentExecution
				.getReferencedDocumentHeader().getBuFmisDocumentId())
				: bufmisdoc;
		refdocid = NumberUtils.toInt(paymentExecution
				.getReferencedDocumentHeader().getBuFmisDocumentId());
		bufmisven = StringUtils.trimToEmpty(paymentExecution
				.getBuFmisVendorId());
		f41vid = paymentExecution.getMasterVendorId() != null ? Long
				.toString(paymentExecution.getMasterVendorId()) : " ";
		f41svi = StringUtils.trimToEmpty(paymentExecution.getSapVendorId());
		amount = paymentExecution.getAmount();
		invlcam = paymentExecution.getLocalCurrencyAmount();
		payref = StringUtils
				.trimToEmpty(paymentExecution.getPaymentReference());
		paydate = PomocnaDatum.XMLDatumUNumDatum(paymentExecution
				.getPaymentDate());
		payecstty = paymentExecution.getPaymentExecutionStatusType() != null ? paymentExecution
				.getPaymentExecutionStatusType().name() : " ";
		paydesc = StringUtils.trimToEmpty(paymentExecution
				.getReferencedDocumentHeader().getDescription());
		resmsgid = resMsg.getResmsgid();
		iscess = paymentExecution.isIsCession() ? "1" : "0";
		datetimews = PomocnaDatum.XMLDatumUDate(messageHeader
				.getSubmitionTimestamp());
		timews = PomocnaDatum.XMLDatumUDate(messageHeader
				.getSubmitionTimestamp());
	}
}
